﻿using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public abstract class UIBase : MonoBehaviour
{
    public bool IsOpen()
    {
        return gameObject.activeSelf;
    }

    virtual public void Open()
    {
        if (!IsOpen())
        {
            gameObject.SetActive(true);
        }
        Refresh();
    }

    virtual public void Open<T>(T data)
    {
       if (!IsOpen())
       {
           gameObject.SetActive(true);
       }
       Refresh(data);
    }

    virtual public void Open<T,T1>(T data,T1 data1)
    {
        if (!IsOpen())
        {
            gameObject.SetActive(true);
        }
        Refresh(data,data1);
    }

    virtual public void Open<T,T1,T2>(T data,T1 data1,T2 data2)
    {
        if (!IsOpen())
        {
            gameObject.SetActive(true);
        }
        Refresh(data,data1,data2);
    }

    virtual public void Open<T,T1,T2,T3>(T data,T1 data1,T2 data2,T3 data3)
    {
        if (!IsOpen())
        {
            gameObject.SetActive(true);
        }
        Refresh(data,data1,data2,data3);
    }

    public virtual void Refresh()
    {

    }

    public virtual void Refresh<T>(T data)
    {

    }

    public virtual void Refresh<T,T1>(T data,T1 data1)
    {

    }

    public virtual void Refresh<T,T1,T2>(T data,T1 data1,T2 data2)
    {

    }

    public virtual void Refresh<T,T1,T2,T3>(T data,T1 data1,T2 data2,T3 data3)
    {

    }

    public void Close()
    {
        if (IsOpen())
        {
            gameObject.SetActive(false);
        }
    }
}
